package com.huqing.icu.rentreport.controller.admin;

import com.huqing.icu.base.BaseController;
import com.huqing.icu.base.IdReq;
import com.huqing.icu.rentreport.inout.in.admin.AdminReportTypeConfigListQueryReq;
import com.huqing.icu.rentreport.inout.in.admin.AdminReportTypeConfigSaveReq;
import com.huqing.icu.rentreport.service.admin.IAdminReportTypeConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 举报类型配置接口
 * @Author huqing
 * @Date 2025/7/6 13:20
 **/
@RestController
@RequestMapping("/api-admin/report_type_config")
@Tag(name = "后台-举报类型配置接口")
public class AdminReportTypeConfigController extends BaseController {

    @Autowired
    private IAdminReportTypeConfigService iAdminReportTypeConfigService;

    @Operation(summary = "新增或修改举报记录")
    @RequestMapping(value = "/save", method = RequestMethod.POST, produces = "application/json")
    public String addReport(@RequestBody AdminReportTypeConfigSaveReq saveReq, HttpServletRequest request) {
        Long userId = checkAndGetUserId(request);
        return jsonSuccess(iAdminReportTypeConfigService.save(saveReq, userId));
    }

    @Operation(summary = "查询举报类型列表")
    @RequestMapping(value = "/query_list", method = RequestMethod.POST, produces = "application/json")
    public String queryList(@RequestBody AdminReportTypeConfigListQueryReq queryReq, HttpServletRequest request) {
        Long userId = checkAndGetUserId(request);
        return jsonSuccess(iAdminReportTypeConfigService.queryList(queryReq));
    }

    @Operation(summary = "删除举报类型")
    @RequestMapping(value = "/add_report", method = RequestMethod.POST, produces = "application/json")
    public String addReport(@RequestBody IdReq idReq, HttpServletRequest request) {
        Long userId = checkAndGetUserId(request);
        return jsonSuccess(iAdminReportTypeConfigService.delete(idReq.getIdList()));
    }
}
